home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / music4c.sit / Music4C Folder / SFConvert folder / progressDialog.c < prev    next >
C/C++ Source or Header  |  1990-06-25  |  2KB  |  91 lines

  1. #include    "SFConvert.h"
  2.  
  3.  
  4.  
  5. static    int            type;
  6. static    DialogPtr    myDialog;
  7. static    int            item;
  8.  
  9. static    Handle         aHand;
  10. static    Rect        prgBox;
  11. static    double        barStep;
  12. static    GrafPtr        save_port;
  13. static    int            NumberOfRecordsToWrite;
  14. static    int            rightPoint;
  15. static    char        c;
  16. static    Rect        aRect;
  17. static    Rect        tRect;
  18.  
  19. static    EventRecord        event;
  20. static    Point        where;
  21.  
  22. extern    long        RecLength;
  23.  
  24. extern    long    fileSize;
  25. extern    int        nrec;
  26.  
  27.  
  28. void    SetProgressDialog()
  29. {
  30.     Rect    tempRect;
  31.     
  32.     GetPort(&save_port);
  33.     myDialog = GetNewDialog(DISPLAY_DIALOG, NIL, (WindowPtr) -1);
  34.     tempRect.top = myDialog->portRect.top;
  35.     tempRect.left = myDialog->portRect.left;
  36.     tempRect.bottom = myDialog->portRect.bottom;
  37.     tempRect.right = myDialog->portRect.right;
  38.     tempRect.top = ((screenBits.bounds.bottom - screenBits.bounds.top) - (tempRect.bottom - tempRect.top)) / 2;
  39.     tempRect.left = ((screenBits.bounds.right - screenBits.bounds.left) - (tempRect.right - tempRect.left)) / 2;
  40.     MoveWindow(myDialog, tempRect.left, tempRect.top, TRUE);
  41.     ParamText("\p", "\p", "\p", "\p");
  42.     ShowWindow(myDialog);
  43.     DrawDialog(myDialog);
  44.     SelectWindow(myDialog);
  45.     SetPort(myDialog);
  46.     
  47.  
  48.     GetDItem(myDialog, 1, &type, &aHand, &prgBox);
  49.     PenSize(3, 3);
  50.     InsetRect(&prgBox, -4, -4);
  51.     FrameRoundRect(&prgBox, 16, 16); 
  52.     PenSize(1, 1); 
  53.  
  54.  
  55.     GetDItem(myDialog, 2, &type, &aHand, &prgBox);
  56.     NumberOfRecordsToWrite = (int) ((fileSize / RecLength) + 0.5);
  57.     barStep = (double)(prgBox.right - prgBox.left ) / (double)NumberOfRecordsToWrite;
  58.  
  59.     FrameRect(&prgBox);
  60.  
  61. }
  62.  
  63.  
  64. Boolean    UpdateProgressDialog()
  65. {
  66.     rightPoint = prgBox.left + (nrec * barStep);
  67.     if ( rightPoint > prgBox.right )
  68.         rightPoint = prgBox.right;
  69.     if ( nrec == NumberOfRecordsToWrite )
  70.         rightPoint = prgBox.right;
  71.         
  72.     SetRect(&aRect, prgBox.left, prgBox.top, rightPoint, prgBox.bottom);
  73.     FillRect(&aRect, gray);
  74.     
  75.     if ( GetNextEvent(mDownMask, &event) ) {
  76.         where = event.where;
  77.         GlobalToLocal(&where);
  78.         GetDItem(myDialog, 1, &type, &aHand, &tRect);
  79.         if ( PtInRect(where, &tRect)) {
  80.             InitCursor();
  81.             InvertRect(&tRect); 
  82.             return(FALSE);
  83.         }
  84.     }
  85.     return(TRUE);
  86. }
  87.  
  88. void    DisposeProgDialog()
  89. {
  90.     DisposDialog(myDialog);
  91. }